﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RemoteTestRunner.BusinessLogic.Views;
using System.IO;

namespace RemoteTestRunner.FormsUI.Wpf
{
    internal class FileOpenDialogService : IFileOpenDialogService
    {
        public string ShowFileOpenDialog(string initialDirectory, string defaultFileName, string DefaultExt, string filter)
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();

            if (!Directory.Exists(Path.GetDirectoryName(initialDirectory)))
            {
                initialDirectory = string.Empty;
            }

            dialog.InitialDirectory = initialDirectory;
            dialog.FileName = defaultFileName;
            dialog.DefaultExt = DefaultExt;
            dialog.Filter = filter;

            if (dialog.ShowDialog() == true)
            {
                return dialog.FileName;
            }
            else
            {
                return null;
            }
        }
    }
}
